package xx.boot.auth.exception;

import cn.dev33.satoken.exception.NotPermissionException;
import cn.dev33.satoken.exception.NotRoleException;
import cn.dev33.satoken.util.SaResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    // 全局异常拦截
    @ExceptionHandler
    public SaResult handlerException(Exception e) {
        e.printStackTrace();
        return SaResult.error(e.getMessage());
    }


    @ExceptionHandler
    public SaResult handlerNotPermissionException(NotPermissionException e) {
        e.printStackTrace();
        return SaResult.error(e.getMessage());
    }


    @ExceptionHandler
    public SaResult handlerNotRoleException(NotRoleException e) {
        e.printStackTrace();
        return SaResult.error(e.getMessage());
    }
}

